<template>
	<view class='pagesSearchBox' v-if="show">
		<view class="btnTop">
			<u-button @click="showDailog" type="primary" icon="search" size='mini' plain>点击搜索</u-button>
		</view>
		<u-popup :show="popupShow" @close="closeDailog" mode='center' round='10rpx' :customStyle="{width:'90%'}"
			closeable>
			<view class="detailContent">
				<view class="searchBox">
					<u--form labelPosition="left" labelWidth='140' :model="queryParams" :labelStyle="{fontWeight:700}">
						<u-form-item v-if="currentCode=='expressList'" label="快递单号" prop="expressNumber">
							<u--input clearable v-model="queryParams.expressNumber" placeholder="请输入快递单号" @input="handleInput(1)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'||currentCode=='detectionList'||currentCode=='consultationApplyList'||currentCode=='customerList'||currentCode=='askList'" label="订单ID" prop="id" >
							<u--input clearable v-model="queryParams.id" placeholder="请输入订单ID" @input="handleInput(5)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='expressList'||currentCode=='interact'" label="订单ID" prop="orderId" >
							<u--input clearable v-model="queryParams.orderId" placeholder="请输入订单ID" @input="handleInput(2)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'||currentCode=='detectionList'||currentCode=='expressList'||currentCode=='consultationApplyList'||currentCode=='customerList'||currentCode=='askList'"  label="订单号" prop="serialNumber">
							<u--input clearable v-model="queryParams.serialNumber" placeholder="请输入订单号" @input="handleInput(3)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='askList'" label="申请时间" prop="createdRange">
							<uni-datetime-picker @change="changeTimeAskList" v-model="createdRange" type="datetimerange"
								rangeSeparator="至" />
						</u-form-item>
						<u-form-item v-if="currentCode=='consultationApplyList'||currentCode=='customerList'" label="订单类型" prop="orderType">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.orderType' :currentCode='currentCode' searchApi='orderType'
									@refreshData="refreshOrderType" placeholder='请选择订单类型'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'||currentCode=='detectionList'||currentCode=='expressList'||currentCode=='interact'||currentCode=='consultationApplyList'||currentCode=='customerList'||currentCode=='askList'" label="患者姓名" prop="name">
							<u--input clearable v-model="queryParams.name" placeholder="请输入患者姓名" @input="handleInput(4)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='consultationApplyList'||currentCode=='customerList'||currentCode=='askList'" label="联系人姓名"  labelWidth='200' prop="contact">
							<u--input clearable v-model="queryParams.contact" placeholder="请输入联系人姓名" @input="handleInput(10)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='transferInfo'" label="患者姓名" prop="name">
							<u--input clearable v-model="queryParams.patientName" placeholder="请输入患者姓名" @input="handleInput(9)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='askList'" label="送检医生电话" labelWidth='200'  prop="sendDoctorTel">
							<u--input clearable v-model="queryParams.sendDoctorTel" placeholder="请输入送检医生电话" @input="handleInput(11)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='consultationApplyList'||currentCode=='customerList'||currentCode=='askList'" label="患者性别" prop="sex">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.sex' :currentCode='currentCode' searchApi='getSexList'
									@refreshData="refreshGetSexList" placeholder='请选择患者性别'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='askList'" label="诊断状态" prop="serviceStatus">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.serviceStatus' :currentCode='currentCode' searchApi='serviceStatus'
									@refreshData="refreshServiceStatus" placeholder='请选择诊断状态'></searchSelect>
							</view>
						</u-form-item>
						
						<u-form-item v-if="currentCode=='extraProject'" label="支付状态" prop="extraProjectStatus">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.extraProjectStatus' :currentCode='currentCode' searchApi='extraProjectStatus'
									@refreshData="refreshExtraProjectStatus" placeholder='请选择支付状态'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'||currentCode=='detectionList'" label="录入状态" prop="resultEntryStatus">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.resultEntryStatus'  :currentCode='currentCode' searchApi='resultEntryStatus'
									@refreshData="refreshResultEntryStatus" placeholder='请选择录入状态'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'" label="申请机构" prop="sendingHospitalId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.sendingHospitalId' :currentCode='currentCode' searchApi='getInstitutionSearch'
									@refreshData="refreshSendingHospitalId" placeholder='请选择申请机构'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'" label="会诊机构" prop="serviceCenterId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.serviceCenterId' :currentCode='currentCode' searchApi='getInstitutionSearch'
									@refreshData="refreshServiceCenterId" placeholder='请选择会诊机构'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='extraProject'" label="开单时间" prop="createdRange">
							<uni-datetime-picker @change="changeTimeExtraProject" v-model="createdRange" type="datetimerange"
								rangeSeparator="至" />
						</u-form-item>
						
						
						<u-form-item v-if="currentCode=='expressList'" label="寄送机构" prop="sendingCourierId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.sendingCourierId' :currentCode='currentCode' searchApi='getInstitutionSearch'
									@refreshData="refreshSendingCourierId" placeholder='请选择寄送机构'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='expressList'" label="签收状态" prop="receiveStatus">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.receiveStatus'  :currentCode='currentCode' searchApi='receiveStatus'
									@refreshData="refreshReceiveStatus" placeholder='请选择签收状态'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='expressList'" label="接收机构" prop="receivingCourierId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.receivingCourierId' :currentCode='currentCode' searchApi='getInstitutionSearch'
									@refreshData="refreshReceivingCourierId" placeholder='请选择接收机构'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='expressList'" label="寄送时间" prop="createdRange">
							<uni-datetime-picker @change="changeTime" v-model="createdRange" type="datetimerange"
								rangeSeparator="至" />
						</u-form-item>
						<u-form-item v-if="currentCode=='detectionList'" label="检测机构" prop="serviceCenterId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.serviceCenterId' :currentCode='currentCode' searchApi='getInstitutionSearch'
									@refreshData="refreshServiceCenterId" placeholder='请选择检测机构'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='transferInfo'" label="医院名称" prop="visitingHospitalId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.visitingHospitalId' :currentCode='currentCode' searchApi='getDaizhuanAllIntitutions'
									@refreshData="refreshVisitingHospitalId" placeholder='请选择医院名称'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='transferInfo'" label="资料状态" prop="dataUploadStatus">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.dataUploadStatus'  :currentCode='currentCode' searchApi='dataUploadStatus'
									@refreshData="refreshDataUploadStatus" placeholder='请选择资料状态'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='transferInfo'" label="病区" prop="ward">
							<u--input clearable v-model="queryParams.ward" placeholder="请输入病区" @input="handleInput(6)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='transferInfo'" label="申请时间" prop="createdRange">
							<uni-datetime-picker @change="changeTimeTransferInfo" v-model="createdRange" type="datetimerange"
								rangeSeparator="至" />
						</u-form-item>
						<u-form-item v-if="currentCode=='interact'" label="患者手机号" labelWidth='200'  prop="phone">
							<u--input clearable v-model="queryParams.phone" placeholder="请输入患者手机号" @input="handleInput(7)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesGuide'" label="标题" prop="title">
							<u--input clearable v-model="queryParams.title" placeholder="请输入文章标题" @input="handleInput(8)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesGuide'" label="科普类型" prop="type">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.type'  :currentCode='currentCode' searchApi='articleType'
									@refreshData="refreshArticleType" placeholder='请选择科普类型'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesGuide'" label="专栏" prop="articleColumnName">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.articleColumnName' :currentCode='currentCode' searchApi='articleTypeRequest'
									@refreshData="refreshArticleColumnName" placeholder='请选择专栏'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesGuide'" label="亚专科" prop="subspecialty">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.subspecialty' :currentCode='currentCode' searchApi='subspecialtyRequest'
									@refreshData="refreshSubspecialty" placeholder='请选择亚专科'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesGuide'" label="科普类别" prop="displayLocation">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.displayLocation' :currentCode='currentCode' searchApi='articleDisplayLocationRequest'
									@refreshData="refreshDisplayLocation" placeholder='请选择科普类别'></searchSelect>
							</view>
						</u-form-item>
						
						<u-form-item v-if="currentCode=='pagesExpert'" label="专家姓名" prop="name">
							<u--input clearable v-model="queryParams.name" placeholder="您想搜索的专家姓名" @input="handleInput(4)"></u--input>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesExpert'"  labelWidth='200' label="专家所在医院" prop="institutionId">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.institutionId' :currentCode='currentCode' searchApi='institutions'
									@refreshData="refreshInstitutionId" placeholder='请选择专家所在医院'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesExpert'"  label="专家职称" prop="medicalTitle">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.medicalTitle' :currentCode='currentCode' searchApi='TitleForClinic'
									@refreshData="refreshMedicalTitle" placeholder='请选择专家职称'></searchSelect>
							</view>
						</u-form-item>
						<u-form-item v-if="currentCode=='pagesExpert'"  label="专家擅长" prop="proficientIn">
							<view class="inputBox" id="searchSelectBox">
								<searchSelect v-if='isReset' :selectValue='queryParams.proficientIn' :currentCode='currentCode' searchApi='PathologicalClass'
									@refreshData="refreshProficientIn" placeholder='请选择专家擅长'></searchSelect>
							</view>
						</u-form-item>
						
						<u-form-item v-if="currentCode=='pagesDetection'" label="检测名称" prop="name">
							<u--input clearable v-model="queryParams.name" placeholder="请输入检测名称" @input="handleInput(4)"></u--input>
						</u-form-item>
						
						
					</u--form>
				</view>
				<view class="btnBox">
					<!-- plain -->
					<view class="btn1 ">
						<u-button class="custom-style" @click="reset" size="mini">
							重置
						</u-button>
					</view>
					<view class="btn1 active">
						<u-button class="custom-style" @click="search" type="primary" size="mini">
							搜索
						</u-button>
					</view>
				</view>
				
			</view>
			

		</u-popup>
	</view>
</template>

<script>
	import searchSelect from '@/components/searchSelect/searchSelect.vue'
	export default {
		name: "searchBox",
		components:{
			searchSelect
		},
		props: {
			show: {
				type: Boolean,
				default: true
			},
			currentCode: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				popupShow: false,
				queryParams: {
					page: 0,
					size: 10
				},
				createdRange: [],
				isReset:true,
				
			};
		},
		mounted() {
			// console.log('currentCode====--',this.currentCode)
		},
		methods: {
			showDailog(){
				this.popupShow=true
				this.$emit('showDailog')
			},
			closeDailog(){
				this.popupShow=false
				this.$emit('closeDailog')
			},
			refreshGetSexList(data){
				if(data){
					this.queryParams.sex = data.value
				}else{
					this.queryParams.sex =''
				}
			},
			refreshServiceStatus(data){
				if(data){
					this.queryParams.serviceStatus = data.value
				}else{
					this.queryParams.serviceStatus =''
				}
			},
			refreshExtraProjectStatus(data){
				if(data){
					this.queryParams.extraProjectStatus = data.value
				}else{
					this.queryParams.extraProjectStatus =''
				}
			},
			refreshResultEntryStatus(data){
				if(data){
					this.queryParams.resultEntryStatus = data.value
				}else{
					this.queryParams.resultEntryStatus =''
				}
			},
			refreshSendingHospitalId(data){
				if(data){
					this.queryParams.sendingHospitalId = data.value
				}else{
					this.queryParams.sendingHospitalId =''
				}
			},
			refreshServiceCenterId(data){
				if(data){
					this.queryParams.serviceCenterId = data.value
				}else{
					this.queryParams.serviceCenterId =''
				}
			},
			refreshVisitingHospitalId(data){
				if(data){
					this.queryParams.visitingHospitalId = data.value
				}else{
					this.queryParams.visitingHospitalId =''
				}
			},
			refreshDataUploadStatus(data){
				if(data){
					this.queryParams.dataUploadStatus = data.value
				}else{
					this.queryParams.dataUploadStatus =''
				}
			},
			refreshDisplayLocation(data){
				if(data){
					this.queryParams.displayLocation = data.value
				}else{
					this.queryParams.displayLocation =''
				}
			},
			refreshInstitutionId(data){
				if(data){
					this.queryParams.institutionId = data.value
				}else{
					this.queryParams.institutionId =''
				}
			},
			refreshMedicalTitle(data){
				if(data){
					this.queryParams.medicalTitle = data.value
				}else{
					this.queryParams.medicalTitle =''
				}
			},
			refreshProficientIn(data){
				if(data){
					this.queryParams.proficientIn = data.value
				}else{
					this.queryParams.proficientIn =''
				}
			},
			refreshSubspecialty(data){
				if(data){
					this.queryParams.subspecialty = data.value
				}else{
					this.queryParams.subspecialty =''
				}
			},
			refreshArticleColumnName(data){
				if(data){
					this.queryParams.articleColumnName = data.value
				}else{
					this.queryParams.articleColumnName =''
				}
			},
			refreshArticleType(data){
				if(data){
					this.queryParams.type = data.value
				}else{
					this.queryParams.type =''
				}
			},
			refreshOrderType(data){
				if(data){
					this.queryParams.orderType = data.value
				}else{
					this.queryParams.orderType =''
				}
			},
			changeTimeExtraProject(e) {
				this.createdRange = e
				console.log('changeTime事件--:', this.createdRange);
				if(this.createdRange.length>0){
					this.queryParams.billingStartTime=this.createdRange[0]
					this.queryParams.billingEndTime=this.createdRange[1]
				}else{
					this.queryParams.billingStartTime=''
					this.queryParams.billingEndTime=''
				}
			},
			changeTimeAskList(e) {
				this.createdRange = e
				console.log('changeTimeAskList事件--:', this.createdRange);
				if(this.createdRange.length>0){
					this.queryParams.startOperationTime=this.createdRange[0]
					this.queryParams.endOperationTime=this.createdRange[1]
				}else{
					this.queryParams.startOperationTime=''
					this.queryParams.endOperationTime=''
				}
			},
			refreshSendingCourierId(data){
				if(data){
					this.queryParams.sendingCourierId = data.value
				}else{
					this.queryParams.sendingCourierId =''
				}
			},
			refreshReceiveStatus(data){
				if(data){
					this.queryParams.receiveStatus = data.value
				}else{
					this.queryParams.receiveStatus =''
				}
			},
			refreshReceivingCourierId(data){
				if(data){
					this.queryParams.receivingCourierId = data.value
				}else{
					this.queryParams.receivingCourierId =''
				}
			},
			changeTime(e) {
				this.createdRange = e
				console.log('changeTime事件--:', this.createdRange);
				if(this.createdRange.length>0){
					this.queryParams.sendStartTime=this.createdRange[0]
					this.queryParams.sendEndTime=this.createdRange[1]
				}else{
					this.queryParams.sendStartTime=''
					this.queryParams.sendEndTime=''
				}
			},
			changeTimeTransferInfo(e) {
				this.createdRange = e
				console.log('changeTime事件--:', this.createdRange);
				if(this.createdRange.length>0){
					this.queryParams.startTime=this.createdRange[0]
					this.queryParams.endTime=this.createdRange[1]
				}else{
					this.queryParams.startTime=''
					this.queryParams.endTime=''
				}
			},
			handleInput(num) {
				if(num==1){
					this.queryParams.expressNumber = uni.$u.trim(this.queryParams.expressNumber)
				}else if(num==2){
					this.queryParams.orderId = uni.$u.trim(this.queryParams.orderId)
				}else if(num==3){
					this.queryParams.serialNumber = uni.$u.trim(this.queryParams.serialNumber)
				}else if(num==4){
					this.queryParams.name = uni.$u.trim(this.queryParams.name)
				}else if(num==5){
					this.queryParams.id = uni.$u.trim(this.queryParams.id)
				}else if(num==6){
					this.queryParams.ward = uni.$u.trim(this.queryParams.ward)
				}else if(num==7){
					this.queryParams.phone = uni.$u.trim(this.queryParams.phone)
				}else if(num==8){
					this.queryParams.title = uni.$u.trim(this.queryParams.title)
				}else if(num==9){
					this.queryParams.patientName = uni.$u.trim(this.queryParams.patientName)
				}else if(num==10){
					this.queryParams.contact = uni.$u.trim(this.queryParams.contact)
				}else if(num==11){
					this.queryParams.sendDoctorTel = uni.$u.trim(this.queryParams.sendDoctorTel)
				}
			},
			search() {
				this.queryParams.page=0
				this.queryParams.size=10
				this.$emit('handleSearch',this.queryParams)
				this.popupShow=false
				this.$emit('closeDailog')

			},
			reset(){
				this.isReset=false
				this.queryParams={
					page: 0,
					size: 10
				}
				this.createdRange=[]
				setTimeout(()=>{
					this.isReset=true
					this.queryParams.page=0
					this.queryParams.size=10
					this.$emit('handleSearch',this.queryParams)
				},500)
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	#searchSelectBox {
		/deep/ .uni-select__input-box {
			
		}

		/deep/ .uni-select {
			
			min-height: 28rpx;
			border: none;
			padding: 0px;
		}

		/deep/ .uni-icons {
			font-size: 24rpx !important;
		}

	}

	.pagesSearchBox {
		padding: 10rpx;

		.btnTop {
			::v-deep .u-cell__title-text {
				font-size: 30rpx;
				font-weight: bold;
				line-height: 40rpx;
				text-align: center;
			}


		}

		.detailContent {
			margin-top: 58rpx;
			padding: 6rpx;
			// max-height: 80vh;
			// overflow: hidden;
			// overflow-y: auto;

			.searchBox {
				font-weight: normal;
				text-align: left;
				font-size: 30rpx;
				line-height: 40rpx;

				::v-deep .u-form-item__body {
					padding: 5rpx 0 !important;
				}

				.inputBox {
					width: 100%;
					height: 56rpx;
					padding: 9rpx 15rpx;
					border: 2rpx solid #E1E0E3;
					border-radius: 8rpx;
					display: flex;
					align-items: center;

				}

			}
			.btnBox {
				display: flex;
				align-items: center;
				justify-content: center;
			    padding:32rpx 0rpx;
				.btn1 {
					
					.custom-style {
						font-size: 30rpx;
					}
				}
				.btn1.active{
					margin-left:80rpx;
				}
			}
		}


	}
</style>